

<template>
    <div class="search-wrap">
        <article class="search-main clearfix">
            <div class="pull-left">
                <Button type='info' @click="handleModal('export')"  icon="plus">导出</Button>
            </div>
            <div class="pull-right">
                <Form :label-width="70" inline>
                    <FormItem label='账户组织'>
                        <Select  v-model="formData.EQ_organizationId" filterable clearable>
                            <Option v-for="item in systemlist" :value="item.id" :key="item.id">{{item.name}}</Option>
                        </Select>
                    </FormItem>
                     <FormItem label='tracking No'>
                        <Input  v-model="formData.EQ_trackingNo"/>
                    </FormItem>
                    <FormItem label='类型'>
                        <Select  v-model="formData.EQ_type" filterable clearable>
                            <Option value="0" key="0">收入</Option>
                            <Option value="1" key="1">支出</Option>
                        </Select>
                    </FormItem>
                    <FormItem label='二级分类'>
                        <Select  v-model="formData.EQ_category" filterable clearable>
                            <Option value="0" key="0">充值</Option>
                            <Option value="1" key="1">扣费</Option>
                            <Option value="4" key="4">退款</Option>
                            <Option value="2" key="2">冻结</Option>
                            <Option value="3" key="3">解冻</Option>
                        </Select>
                    </FormItem>
                    <FormItem  label='交易时间' >
                        <DatePicker type="daterange"  v-model="formData.BT_createdAt"></DatePicker>
                    </FormItem>
					<FormItem :label-width="1">
                        <Button type="primary" @click="update" icon="ios-search-strong">搜索</Button>
                        <Button @click="reset" icon='refresh'>重置</Button>
                    </FormItem>
                </Form>
            </div>
        </article>
    </div>
</template>

<script>
import DateFormat from '@/utils/date';
import { mapState } from 'vuex';

export default {
    data() {
        return {
            formData: {
                EQ_type: null,
                
            },
        }
    },
    mounted() {
        this.update();
    },
    computed: {
        ...mapState(['systemlist'])
    },
    methods: {
        handleModal(type, id) {
            this.$parent.handleOperate(id, type);
        },
        update() {
            const search = { ...this.formData };
            search.BT_createdAt = (search.BT_createdAt && search.BT_createdAt[0]) ? (DateFormat(search.BT_createdAt[0], 'yy-mm-dd') + ' ~ ' + DateFormat(search.BT_createdAt[1], 'yy-mm-dd')) : '';
            this.$emit('on-update', { search });
        },
        reset() {
            this.formData = {
                EQ_organizationId: '',
                BT_createdAt: '',
                EQ_trackingNo: '',
                EQ_type: null,
            };
            this.$emit('on-update', { search: this.formData });
        },
    },
};

</script>
